home *** CD-ROM | disk | FTP | other *** search
/ Delphi Informant Complete 1995 - 2000 / Delphi Informant Complete 1995 to 2000.iso / Delphi Informant Magazine Complete Works SOURCE CODE 1998.rar / 1998 / Nov / di9811gd / Example1 / DllCode.pas < prev    next >
Pascal/Delphi Source File  |  1997-11-02  |  1KB  |  56 lines

  1. unit DllCode;
  2.  
  3. interface
  4.  
  5. uses
  6.   Dialogs, SysUtils;
  7.  
  8. { Assume that szResult is at least as long as sz }
  9. procedure GetFirstWord(sz, szResult: PChar); stdcall export;
  10. procedure GetNextWord(sz, szResult: PChar); stdcall export;
  11.  
  12. implementation
  13.  
  14. var
  15.   gCurrentWordIndex: Integer;
  16.  
  17. function FindCurrentWord(st: String): String;
  18. var
  19.   Len, j: Integer;
  20. begin
  21.   j := gCurrentWordIndex; Len := Length(st);
  22.   {* Find where the word begins... *}
  23.   while (j <= Len) and
  24.         (not (st[j] in ['A'..'Z','a'..'z','0'..'9'])) do Inc(j);
  25.   gCurrentWordIndex := j;
  26.   {* Find where the word ends... *}
  27.   while (j <= Len) and
  28.         (st[j] in ['A'..'Z','a'..'z','0'..'9']) do Inc(j);
  29.   result := Copy(st, gCurrentWordIndex, j - gCurrentWordIndex + 1);
  30.   gCurrentWordIndex := j;
  31. end;
  32.  
  33. procedure GetFirstWord(sz, szResult: PChar);
  34. var
  35.   st: String;
  36. begin
  37.   gCurrentWordIndex := 1;
  38.   StrPCopy(szResult, FindCurrentWord(String(sz)));
  39. end;
  40.  
  41. procedure GetNextWord(sz, szResult: PChar);
  42. begin
  43.   StrPCopy(szResult, FindCurrentWord(String(sz)));
  44. end;
  45.  
  46. initialization
  47.  
  48. gCurrentWordIndex := 0;
  49. ShowMessage('Initializing process-level stuff.');
  50.  
  51. finalization
  52.  
  53. ShowMessage('Cleaning up process-level stuff.');
  54.  
  55. end.
  56.